function SOUrlShortService(longUrl, async) {
	this.origUrl = longUrl;
	this.async = async;
}

SOUrlShortService.prototype = {
	/**
	 * http://www.javaeedev.com/blog/article.jspx?articleId=ff80808116c69bf501171fd1d8582f21
	 */
	_request: function(url, data_callback, error_callback, timeout) {
		
		var req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
					.createInstance(Components.interfaces.nsIXMLHttpRequest);
		var scope = this;
		
		// timer
		var event = {
			notify: function(timer) {
				req.abort();
				req.onreadystatechange = null;
				
				error_callback(req);
			}
		};
		
		var timer = Components.classes["@mozilla.org/timer;1"]
		                    .createInstance(Components.interfaces.nsITimer);
		var _timeout = 3000;
		if (timeout) _timeout = timeout;
		timer.initWithCallback(
						   event,
						   _timeout,
						   Components.interfaces.nsITimer.TYPE_ONE_SHOT);
						
		req.onreadystatechange = function() {
			if (req.readyState != 4) {
				// Ignore non-loaded readStates
				// ... will timeout if do not get to "loaded"
				return;
			}
			
			// Cancel the timer
			timer.cancel();
			
			if (req.status == 200) {
				data_callback(req);
			} else {
				error_callback(req);
			}
		}
		
		req.open('GET', url, this.async);
		req.send(null);
	},
	
	shortUrl: function(api, data_callback, error_callback, timeout) {
		var url = encodeURIComponent(this.origUrl);
		// @@
		var cusApi = api.replace("@@", url);
		this._request(cusApi, data_callback, error_callback, timeout);
	}
}